<?php 
namespace Admin\Controller;
use Admin\Controller\AdminController;
use Home\Controller\PublicController;
class ConfigController extends AdminController{
	///配置项主页
	public function index(){
		$this -> display();
	}
	///
	public function updateCofig(){
     	
         if($_FILES["logo"]["name"]){
                $_POST['logo']=$this->upload($_FILES["logo"]);
                if (!$_POST['logo']){
                    $this->error('非法上传');
                }
         }
         if($_FILES["slogo"]["name"]){
         	$_POST['slogo']=$this->upload($_FILES["slogo"]);
         	if (!$_POST['slogo']){
         		$this->error('非法上传');
         	}
         }
         if($_FILES["mpic"]["name"]){
            $_POST['mpic']=$this->upload($_FILES["mpic"]);
            if (!$_POST['mpic']){
                $this->error('非法上传');
            }
         }
         if($_FILES["qpic"]["name"]){
            $_POST['qpic']=$this->upload($_FILES["qpic"]);
            if (!$_POST['qpic']){
                $this->error('非法上传');
            }
         }
         if($_FILES["spic"]["name"]){
            $_POST['spic']=$this->upload($_FILES["spic"]);
            if (!$_POST['spic']){
                $this->error('非法上传');
            }
         }

     	foreach ($_POST as $k=>$v){
     		$rs[]=M('Config')->where(C("DB_PREFIX")."config.key='{$k}'")->setField('value',$v);
     	}
     	if($rs){
     		$this->success('配置修改成功');
     	}else{
     		$this->error('配置修改失败');
     	}

     }
}